package com.xyht.sca_s.student_manage_system.modules.assetConsumable.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.assetConsumable.entity.req.SmsAssetConsumableCategoryManagementReq;
import com.xyht.sca_s.student_manage_system.modules.assetConsumable.service.SmsAssetConsumableCategoryManagementService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 资产管理类别管理 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-09-28
 */
@RestController
@RequestMapping("/assetConsumable/categoryManagement")
@SecretBody
public class SmsAssetConsumableCategoryManagementController {

    @Resource
    private SmsAssetConsumableCategoryManagementService smsAssetConsumableCategoryManagementService;

    @ApiModelProperty(value = "类别添加")
    @PostMapping("/add")
    public ResponseResult addCategory(@RequestBody SmsAssetConsumableCategoryManagementReq smsAssetCategoryManagementReq) {
        return smsAssetConsumableCategoryManagementService.addCategory(smsAssetCategoryManagementReq);
    }

    @ApiModelProperty(value = "类别修改")
    @PostMapping("/update")
    public ResponseResult updateCategory(@RequestBody SmsAssetConsumableCategoryManagementReq smsAssetCategoryManagementReq) {
        return smsAssetConsumableCategoryManagementService.updateCategory(smsAssetCategoryManagementReq);
    }
    @ApiModelProperty(value = "类别删除")
    @PostMapping("/delete")
    public ResponseResult deleteCategory(@RequestBody SmsAssetConsumableCategoryManagementReq smsAssetCategoryManagementReq) {
        return smsAssetConsumableCategoryManagementService.deleteCategory(smsAssetCategoryManagementReq);
    }

    @ApiModelProperty(value = "子类别列表")
    @GetMapping("/list")
    public ResponseResult getCategoryChildrenList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                  @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                  @RequestParam(value = "parent_id",required = false) String parent_id,
                                                  @RequestParam(value = "search_str",required = false) String search_str) {
        return smsAssetConsumableCategoryManagementService.getCategoryChildrenList(search_str,parent_id, pageNum, pageSize);
    }

    @ApiModelProperty(value = "类别树")
    @GetMapping("/tree")
    public ResponseResult getCategoryTree() {
        return smsAssetConsumableCategoryManagementService.getCategoryTree();
    }

}

